package com.hdstcloud.device.service.bo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.frame.base.comm.persistence.BoConstraintType;
import com.frame.base.comm.persistence.ConditionMatchMode;
import com.frame.base.comm.persistence.annotaion.BoConstraint;
import com.frame.base.comm.persistence.annotaion.SoleHolder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author Dominic
 */
@Data
@NoArgsConstructor
public class BoDevItem {
    //id == devId + modelItemId
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "JDBC")
    private String id;
    private BoModelItem modelItem;
    private String type;

    @SoleHolder
    @BoConstraint(type = BoConstraintType.CONDITION, attrName = "dataTime", valType = LocalDateTime.class, mode = ConditionMatchMode.BETWEEN)
    private List<BoItemValue> itemValueHis;

    //实时数据/属性项或者配置项的值
    private String rtValue;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime dataTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime systemTime;

    public BoDevItem(BoModelItem modelItem) {
        this.modelItem = modelItem;
    }
}
